package com.hmall.order.comment;

import com.hmall.common.dto.Order;
import com.hmall.order.mapper.OrderMapper;
import com.hmall.order.utils.RabbitMQConfig;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
public class OrderControllerConsumer {
    @Autowired
    private OrderMapper orderMapper;
    @RabbitListener(queues = RabbitMQConfig.DLX_EXCHANGE)
    public void listenner(Integer userId, Date date){
        Order order=orderMapper.getByUserId(userId);
        //如果订单未支付，则显示超时
        if(order.getStatus().equals(1)){
            orderMapper.changestatus(userId);
            System.out.println("订单超时");
        }
    }
}
